package main

import (
	"context"
	"fmt"
	"strconv"

	"git.900sui.cn/kc/base/utils"
	"git.900sui.cn/kc/kcgin"
	"git.900sui.cn/kc/kcgin/logs"
	"git.900sui.cn/kc/rabbitmq"
	"git.900sui.cn/kc/rpcinterface/client/comtreeData"
	comtreeData2 "git.900sui.cn/kc/rpcinterface/interface/comtreeData"
	"github.com/streadway/amqp"
)

func main() {
	rpcConsumer := new(comtreeData.Consumer).Init()

	logs.Info("Environment Variable:MSF_ENV:", kcgin.KcConfig.RunMode)
	new(utils.KcLog).GetInstance(kcgin.AppConfig.String("consumer.log.ETLAddQue"))
	err := rabbitmq.Rabbitmq.Consume(kcgin.AppConfig.String("queue.consumer.users"), func(msg amqp.Delivery) {
		Uid, _ := strconv.Atoi(string(msg.Body))
		fmt.Println("this is success")
		var reply bool
		data := &comtreeData2.ArgsAddConsumer{
			Uid: Uid,
		}
		err := rpcConsumer.AddConsumerRpc(context.Background(), data, &reply)
		if err != nil {
			utils.Logerr.Printf("comtreeData Consumer 数据录入失败，err:%s", err)
		}
	})
	if err != nil {
		utils.Logerr.Printf("comtreeData Consumer 任务错误, err: %s", err.Error())
	}
}
